﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Embedded;

namespace CentrisScraper.Lib
{
    public static class PersistenceManager
    {
        private static IDocumentStore documentStore = null;

        public static void Start()
        {
            if (documentStore != null)
            {
                Stop();
            }
            var x = new EmbeddableDocumentStore();
            x.DataDirectory = "d:\\CentrisScraperData";
            x.Conventions.MaxNumberOfRequestsPerSession = 500;
            documentStore = x.Initialize();

        }

        public static void Stop()
        {
            if (documentStore != null)
            {
                documentStore.Dispose();
                documentStore = null;
            }
        }

        public static IDocumentStore DocumentStore
        {
            get { return documentStore; }
        }
    }
}
